home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power CD-ROM!! 8
/
Power CD-ROM 8.iso
/
prgmming
/
pmd110
/
wmem.dif
< prev
next >
Wrap
Text File
|
1994-11-13
|
4KB
|
160 lines
*** c:\bp\rtl\sys\wmem.asm Wed Oct 28 07:00:00 1992
--- wmem.asm Thu Aug 25 01:01:00 1994
***************
*** 41,44 ****
--- 41,49 ----
ENDIF
+ ;;MemCheck externals
+
+ EXTRN CheckMEM:BYTE,StoreAlloc:DWORD,FreeAlloc:DWORD
+
+
; Local variables
***************
*** 45,48 ****
--- 50,57 ----
AllocSize DW ?
+ ;; Memchecker variable
+
+ MemSize DW ?
+
DATA ENDS
***************
*** 186,192 ****
NewMemory:
OR AX,AX
JE @@7
! MOV AllocSize,AX
@@1: CMP AX,HeapLimit
JB @@2
--- 195,220 ----
NewMemory:
+ ;; memchecker code
+ mov [MemSize],ax
+
OR AX,AX
JE @@7
!
! ;; memchecker code
! ;; add 8 or 16 bytes to allocated memory for overflow checking
!
! cmp CheckMem,0 ; is MemCheck code enabled?
! je @@m1
! cmp ax,65512 ; 65536-8-16
! ja @@CheckUpperArea
! add ax,16
! jmp short @@m1
! @@CheckUpperArea:
! cmp ax,65520 ; 65536-8-8
! ja @@m1
! add ax,8
!
! @@m1:
! MOV AllocSize,AX
@@1: CMP AX,HeapLimit
JB @@2
***************
*** 218,222 ****
@@7: XOR AX,AX
CWD
! @@6: RET
; Allocate global block
--- 246,295 ----
@@7: XOR AX,AX
CWD
! @@6:
!
! ;; memchecker code
! jc @@NoCheck ; if error do not check
! cmp CheckMem,0 ; is MemCheck code enabled
! je @@NoCheck
! mov cx,MemSize
! jcxz @@NoCheck ; if size = 0, don't check
! cmp dx,0 ; check if returned pointer is nil
! je @@NoCheck ; don't check
!
! cmp cx,65520 ; is there room for upper memory check?
! ja @@StorePointer
! mov si,ax ; save ax
! mov es,dx
! mov di,ax
! add di,cx
! cmp cx,65512
! ja @@m2
! add di,8 ; correct if we have a lower memory also
! @@m2: mov ax,0cccch ; fill last 8 bytes with 0CCh
! mov cx,4
! cld
! rep stosw
! mov ax,si ; restore ax
! mov cx,MemSize
!
! cmp cx,65512 ; is there room for lower memory check?
! ja @@StorePointer
! mov es,dx
! mov di,ax
! mov ax,0cccch ; fill first 8 bytes with 0CCh
! mov cx,4
! cld
! rep stosw
! mov ax,di ; first 8 bytes are skipped
!
! @@StorePointer:
! push dx ; push ptr
! push ax
! push [MemSize] ; else push size
! call dword ptr [StoreAlloc]
! @@NoCheck:
!
! RET
! ;ENDP
; Allocate global block
***************
*** 356,359 ****
--- 429,457 ----
DisMemory:
+ ;; memchecker code
+ cmp CheckMem,0
+ je @@DisMemoryStart
+ or ax,ax ; if Size = 0
+ jne @@m1
+ jmp @@4 ; then no check
+ @@m1:
+ push bx ; push ptr
+ push cx
+ push ax ; push size
+ call dword ptr [FreeAlloc]
+
+ ;; add the extra overflow memory area size
+ cmp ax,65512 ; 65536-8-16
+ ja @@UpperArea
+ add ax,16
+ sub cx,8
+ jmp short @@DisMemoryStart
+ @@UpperArea:
+ cmp ax,65520 ; 65536-8-8
+ ja @@DisMemoryStart
+ add ax,8
+
+ @@DisMemoryStart:
+
OR AX,AX
JE @@4
***************
*** 429,432 ****
--- 527,531 ----
@@9: MOV HeapList,AX
JMP @@6
+
CODE ENDS